﻿/// <summary>
/// 
///	Author:		    Gerard Finn
///
///	Student No		X00115840
///
///	Date:			Start Date 	:- 05-04-2014
///	Modified					:-
/// 
/// File            IOClass.cs
///   
///	Description		Class to isolate the input and output from all other
///	                classes allowing for changing IO stream in a single place
///
/// </summary>

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace Client
{
    /// <summary>
    /// 
    ///  Class for obtaining and displaying data
    ///  
    ///  This is the only class which will need to be changed to allow 
    ///  for data to be obtained fron another input / output stream just
    ///  change insert a relevant class with the same public interface and
    ///  functions 
    ///  
    ///  This is done this way as it is my prefered way of implementing stuff
    ///  which has to be allowed to be altered as the spec required that it be
    ///  able to be used for the console as an initial first step and should
    ///  be allowable to change for usage with a mobile phone interface this
    ///  is the only class where alterations would be required
    ///  
    ///  If there was going to be multiple different output streams being allowed
    ///  for it could have been done using a template with an input param of the 
    ///  stream type
    /// 
    /// </summary>
    public class IOClass
    {
        /// <summary>
        /// 
        ///  Function to clear the screen
        /// 
        /// </summary>
        public static void Clear()
        {
            Console.Clear();
        }
        /// <summary>
        /// 
        ///  Function to read input data
        /// 
        ///  Returns a string to the caller
        /// 
        /// </summary>
        public static String ReadLine()
        {
            return Console.ReadLine();
        }
        /// <summary>
        /// 
        ///  Function to write data to the output stream
        ///  
        /// param   : object[] list is a var args array to be displayed
        ///           outputs a newline after all data has been written
        ///           
        /// return  : nothing
        /// 
        /// </summary>
        public static void WriteLine(params object[] list)
        {
            foreach (object obj in list)
                Console.Write(obj.ToString() + " ");
            Console.WriteLine();
        }
        /// <summary>
        /// 
        ///  Function to write data to the output stream
        ///  
        /// param   : object obj is an item to displayed and its default
        ///           toString function is used if there isnt one written for 
        ///           the object input
        ///           
        ///           outputs a new line after the data has been displayed
        /// 
        /// return  : nothing
        /// 
        /// </summary>
        public static void WriteLine(object obj)
        {
            Console.WriteLine(obj != null ? obj.ToString() : "");
        }
        /// <summary>
        /// 
        ///  Function to write data to the output stream without a \n
        ///  
        /// param   : object[] list is a var args array to be displayed
        ///           foreach loop deals with checking for null references
        ///           
        /// return  : nothing
        /// 
        /// </summary>
        public static void Write(params object[] list)
        {
            foreach (object obj in list)
                Console.Write(obj.ToString() + " ");
        }
        /// <summary>
        /// 
        ///  Function to write data to the output stream
        ///  
        /// param   : object obj is an item to displayed
        /// 
        /// return  : nothing
        /// 
        /// </summary>
        public static void Write(object obj)
        {
            Console.Write(obj.ToString());
        }
    }
    /// <summary>
    /// 
    /// Class for displaying error message strings in production 
    /// enviroment this would write to the error output stream
    /// 
    /// </summary>
    public class ErrorMessage
    {
        public static void Display(String message)
        {
            IOClass.WriteLine(message);
        }
    }   // End of class ErrorMessage
    /// <summary>
    /// 
    /// Class for displaying success message strings
    /// 
    /// </summary>
    public class SuccessMessage
    {
        public static void Display(String message)
        {
            IOClass.WriteLine(message);
        }
    }   // End of class SuccessMessage
}
